#pragma once
#include "IGeneticProcess.h"
#include "ISpecimenFactory.h"
#include "Random.h"

#include <string>
#include <list>

class GeneticProcess :
	public IGeneticProcess
{
public:
	GeneticProcess(unsigned int populationCount, unsigned int mutationPercent, unsigned int crosoverPercent, ISpecimenFactory *specimenFactory, Random *generator);
	virtual ~GeneticProcess(void);

	virtual void Initialize();

	virtual void Select();
	virtual void Mutate();
	virtual void Crosover();
	
	virtual std:: string GetBest(unsigned int max_cnt);
	virtual std::string ToString();

private:
	void debug(std::string txt);
	unsigned int m_populationCount;
	unsigned int m_mutationPercent;
	unsigned int m_crosoverPercent;
	ISpecimenFactory *m_specimenFactory;
	Random *m_generator;

	static bool sortPredicate(ISpecimen* lhs, ISpecimen* rhs);
	std::list<ISpecimen*> *m_population;

};
